#include <ftw.h>
#include <string.h>
#include <stdio.h>

int fn(const char *file, const struct stat *sb, int flag, struct FTW *s)
{
        int count =0;

        if( flag == FTW_F )
        {
                if(strstr(file,".php") != NULL
		||strstr(file,".cls") != NULL
		||strstr(file,".inc") != NULL
		||strstr(file,".htm") != NULL
		||strstr(file,".html") != NULL
		||strstr(file,".js") != NULL
		||strstr(file,".css") != NULL
		||strstr(file,".c") != NULL
		||strstr(file,".cpp") != NULL
		||strstr(file,".sql") != NULL
		||strstr(file,".sh") != NULL)
                {
                        printf("\ndos2unix %s", file);
                }
        };

        return 0;
}

int main(int argc, char *argv[])
{
        int result;
	if (argc != 2)
	{
		printf("a single argument (the directory name) is required");
		exit(1);
	}
	//ftw(const char * dir, int (*fn)(const char * file,const struct stat *sb,int flag),int depth)
	ftw(argv[1], fn, 100);
        return 0;
}
